package boot.spring.service.impl;

import boot.spring.mapper.AdminMapper;
import boot.spring.po.Admin;
import boot.spring.po.Staff;
import boot.spring.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    AdminMapper adminMapper;

    @Override
    public Admin getAdminByUsername(String username) {
        return adminMapper.getAdminByUsername(username);
    }

    @Override
    public List<Staff> getAllUsers() {
        return adminMapper.getAllUsers();
    }

    @Override
    public void deleteUserById(int id) {
        adminMapper.deleteUserById(id);
    }

    @Override
    public void deleteUserByIdAndForceLogout(int id, String username) {
        adminMapper.deleteUserById(id);
        boot.spring.service.WebSocketServer.deleteuser(username);
    }

    @Override
    public void insertNotice(String content) {
        adminMapper.insertNotice(content);
    }

    @Override
    public List<Staff> getUsersBySearch(String search, int offset, int size) {
        return adminMapper.getUsersBySearch(search, offset, size);
    }

    @Override
    public Staff getUserById(int id) {
        return adminMapper.getUserById(id);
    }
} 